<template>
  <div class="store_list">
    <Header title="店铺街" :back="true"> </Header>
    <div class="store_msg">
      <van-tabs
        v-model="active"
        color="#ff4f02"
        title-active-color="#ff4f02"
        title-inactive-color="#333"
        @click="onClick"
      >
        <van-tab
          :title="item.sc_name"
          v-for="(item, index) in StoreClass"
          :key="index"
        >
          <div class="shop" v-for="(val, index) in StoreClassList" :key="index">
            <div class="shop_dec">
              <img
                :src="'http://122.51.249.55:3000/' + val.store_logo"
                alt=""
              />
              <div class="shop_name">
                <span>{{ val.store_name }}</span>
                <span>共件{{ val.store_count }}宝贝</span>
              </div>

              <span>
                <router-link :to="'/store/store/' + val.store_id"
                  >进店</router-link
                ></span
              >
            </div>
            <div class="shop_rang">
              <span>宝贝描述:{{ val.store_desccredit }} <i>高</i> </span>
              <span>卖家服务:{{ val.store_servicecredit }}<i>高</i> </span>
              <span>物流服务:{{ val.store_deliverycredit }}<i>高</i> </span>
            </div>
            <!-- 推荐产品图片 -->
            <div class="store_tuijian">
              <ul>
                <li v-for="(values, indx) in val.cartList" :key="indx">
                  <img src="@/assets/imgs/图层 4.png" alt="" />
                  <p>￥{{ values.shop_price }}</p>
                  <p>{{ values.goods_name }}</p>
                </li>
              </ul>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>

<script>
import Header from "@/components/Header";
export default {
  components: {
    Header
  },
  data() {
    return {
      active: 0,
      StoreClass: [], //分类列表
      StoreClassList: [],
      sc_id: 0
    };
  },
  created() {
    this.getStoreClass();
    this.getStoreClassList();
  },
  methods: {
    // 获取分类列表
    async getStoreClass() {
      let { data: res } = await this.$axios.get("Index/storeClass");
      this.StoreClass = res.result;
    },
    // 获取推荐内容
    async getStoreClassList() {
      let { data: res } = await this.$axios.get("Index/storeStreet", {
        params: { sc_id: this.sc_id + 1, p: 1 }
      });
      this.StoreClassList = res.result.store_list;
    },
    onClick(name, title) {
      this.sc_id = name;
      this.getStoreClassList();
    }
  }
};
</script>

<style lang="less" >
.store_list {
  .ct {
    color: #333333;
    font-weight: 700;
    font-family: PingFang-SC-Bold;
  }

  .header .lt[data-v-61dd7a3d] {
    transform: translateY(50%);
    margin-left: 24px;
  }
  .van-tab__text {
    font-size: 28px;
    font-weight: 700;
  }
  .shop {
    padding: 30px 24px;
    background-color: #fff;
    margin-bottom: 20px;
    .shop_dec {
      display: flex;
      justify-content: space-between;
      span {
        font-size: 28px;
      }
      span:nth-child(3) {
        font-size: 28px;
        padding: 0 20px;
        height: 44px;
        line-height: 42px;
        text-align: center;
        border: 1px solid red;
        color: red;
        border-radius: 22px;
      }
      .shop_name {
        display: flex;
        flex-direction: column;
        position: absolute;
        left: 137px;
        span:nth-child(2) {
          color: #666666;
        }
      }
      img {
        width: 94px;
        height: 94px;
      }
    }
    .shop_rang {
      display: flex;
      justify-content: space-between;
      margin-top: 24px;
      font-size: 28px;
      color: #666666;
      margin-bottom: 20px;
      i {
        font-style: normal;
        font-size: 18px;
        color: #fbfbfb;
        width: 26px;
        height: 26px;
        line-height: 26px;
        text-align: center;
        background-color: #ff0000;
        border-radius: 4px;
      }
    }
    ul {
      display: flex;
      flex-wrap: wrap;
      li {
        width: 222px;
        margin-bottom: 20px;
        &:nth-child(even) {
          margin: 0 10px;
        }
        p:nth-child(2) {
          text-align: center;
          transform: translateY(-34px);
          width: 222px;
          height: 34px;
          background-color: #000000;
          opacity: 0.5;
          color: #ffffff;
          font-size: 22px;
        }
        p:nth-child(3) {
          font-size: 20px;
          color: #666666;
          line-height: 30px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }
        img {
          width: 222px;
          height: 222px;
        }
      }
    }
  }
}
</style>
